package com.ruoyi.ItemLog.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ItemLog.domain.TbItemLog;
import com.ruoyi.ItemLog.service.ITbItemLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物品日志管理Controller
 * 
 * @author ruoyi
 * @date 2025-08-04
 */
@RestController
@RequestMapping("/ItemLog/Itemlog")
public class TbItemLogController extends BaseController
{
    @Autowired
    private ITbItemLogService tbItemLogService;

    /**
     * 查询物品日志管理列表
     */
    @PreAuthorize("@ss.hasPermi('ItemLog:Itemlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbItemLog tbItemLog)
    {
        startPage();
        List<TbItemLog> list = tbItemLogService.selectTbItemLogList(tbItemLog);
        return getDataTable(list);
    }

    /**
     * 导出物品日志管理列表
     */
    @PreAuthorize("@ss.hasPermi('ItemLog:Itemlog:export')")
    @Log(title = "物品日志管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbItemLog tbItemLog)
    {
        List<TbItemLog> list = tbItemLogService.selectTbItemLogList(tbItemLog);
        ExcelUtil<TbItemLog> util = new ExcelUtil<TbItemLog>(TbItemLog.class);
        util.exportExcel(response, list, "物品日志管理数据");
    }

    /**
     * 获取物品日志管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('ItemLog:Itemlog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tbItemLogService.selectTbItemLogById(id));
    }

    /**
     * 新增物品日志管理
     */
    @PreAuthorize("@ss.hasPermi('ItemLog:Itemlog:add')")
    @Log(title = "物品日志管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbItemLog tbItemLog)
    {
        return toAjax(tbItemLogService.insertTbItemLog(tbItemLog));
    }

    /**
     * 修改物品日志管理
     */
    @PreAuthorize("@ss.hasPermi('ItemLog:Itemlog:edit')")
    @Log(title = "物品日志管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbItemLog tbItemLog)
    {
        return toAjax(tbItemLogService.updateTbItemLog(tbItemLog));
    }

    /**
     * 删除物品日志管理
     */
    @PreAuthorize("@ss.hasPermi('ItemLog:Itemlog:remove')")
    @Log(title = "物品日志管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbItemLogService.deleteTbItemLogByIds(ids));
    }
}
